package com.ws.shop.bean;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public  class Page implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5247614532234782640L;
	public final static String PAGE = "page";
	public final static String PAGE_NO = "pageno";
	public final static String PAGE_SIZE = "pagesize";
	
	
	
	private int pagesize=30;//每页显示记录数
	private long startrownum=0;//当页开始记录号
	private long totalnum;//总记录数
	private long totalpages;//总页码
	private long currentPageNo=0;//当前页码
	@SuppressWarnings("unchecked")
	private List sumdata=new LinkedList();//此集合可用来保存 合计数据
	@SuppressWarnings("unchecked")
	private List data=new LinkedList();//查询结果
	
	public int getPagesize() {
		return pagesize;
	}
	public void setPagesize(int pagesize) {
		this.pagesize = pagesize;
	}
	public long getStartrownum() {
		startrownum=pagesize * (currentPageNo -1);
		return startrownum;
	}
	public void setStartrownum(long startrownum) {
		this.startrownum = startrownum;
	}
	public long getTotalnum() {
		return totalnum;
	}
	public void setTotalnum(long totalnum) {
		this.totalnum = totalnum;
		if(this.totalnum % pagesize == 0) {
			this.totalpages = this.totalnum/pagesize;
		} else {
			this.totalpages = this.totalnum/pagesize + 1;
		}
	}
	public long getTotalpages() {
		return totalpages;
	}
	public void setTotalpages(long totalpages) {
		this.totalpages = totalpages;
	}
	public long getCurrentPageNo() {
		return currentPageNo;
	}
	public void setCurrentPageNo(long currentPageNo) {
		this.currentPageNo=currentPageNo;
	}
	@SuppressWarnings("unchecked")
	public List getData() {
		return data;
	}
	
	@SuppressWarnings("unchecked")
	public void addData(Object t){
		data.add(t);
	}
	
	@SuppressWarnings("unchecked")
	public void addSumdata(Object t){
		sumdata.add(t);
	}
	
	@SuppressWarnings("unchecked")
	public void setData(List data) {
		this.data = data;
	}
	
	public Page(){}
	
	public Page(long currentPageNo){
		this.currentPageNo=currentPageNo;
	}
	
	public Page(long currentPageNo,int pagesize){
		this.currentPageNo=currentPageNo;
		this.pagesize = pagesize;
	}
	
	@SuppressWarnings("unchecked")
	public List getSumdata() {
		return sumdata;
	}
	@SuppressWarnings("unchecked")
	public void setSumdata(List sumdata) {
		this.sumdata = sumdata;
	}
	
	
	
}
